<template>
	<view class="share-content">
		<view class="share-box">
			<view class="sku-list">
				<view class="sku-item" v-for="item in skuList" :key="item.id">
					<view style="flex: 2; white-space: nowrap;">租期：{{item.title}}</view>
					<view style="flex: 1;white-space: nowrap;">单价：￥{{item.price}}</view>
					<view style="color: #d65128;flex: 1;white-space: nowrap;">预估佣金：￥{{item.commission}}</view>
				</view>
				<view class="tips-box">
					实际佣金以平台扣除相关手续费后为准!
				</view>
			</view>
			<view class="bottom-btn">
				<u-button type="primary" @click="share">分享获佣</u-button>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		GetHouseSkuInfo,
	} from "@/api/index.js"
	export default {
		data() {
			return {
				skuList: [],
				houseId: ''
			}
		},
		onLoad(op) {
			this.houseId = op.id
			this.getSku(op.id)
		},
		methods: {
			getSku(houseId) {
				GetHouseSkuInfo({
					houseId
				}).then(res => {
					this.skuList = res.data
				})
			},
			share() {
				let href =
					`https://aiyouzixun.top/#/pages/houseDetail/index?id=${this.houseId}&shareUserId=${uni.getStorageSync('userInfo').openId}`
				uni.setClipboardData({
					data: href,
					showToast: false,
					success: function() {
						uni.showToast({
							title: "复制成功,去转发吧",
							icon: "success",
							duration: 2000
						});
					},
					fail: function() {
						uni.showToast({
							title: "复制失败，请重新分享",
							icon: "none",
							duration: 2000
						});
					}
				});
			}
		}
	}
</script>

<style lang="scss">
	.sku-list {
		width: 95%;
		margin: 20rpx auto;
		padding: 20rpx;
		background-color: #fff;
		border-radius: 10rpx;

		.sku-item {
			padding: 10rpx 20rpx;
			border-bottom: 1rpx solid #eee;
			display: flex;
			justify-content: space-between;

		}

		.tips-box {
			padding: 20rpx;
		}
	}

	.bottom-btn {
		position: fixed;
		width: 95%;
		bottom: 30rpx;
		left: 2.5%;
	}
</style>